<template>
  <div style="position: relative;">
    <div v-if="!imgShare">
      <head-nav :firstTitle="'数据管理'" :subTitle="'影像列表'"></head-nav>
    </div>

    <div class="contentContainer" :class="{ noCardStyle: !cardStyle }">
      <div class="content">
        <div ref="condationHeight" class="ml10 mt5 mb">
          <condition-inquery :match_state="formData.match_state" :systemsLiteList="systemsLiteList"
            :room_ids="ObservationRoomIds" :clear_select="clear_select" :imgShare="imgShare" :nodeList="nodeList"
            @setMatchState="setMatchState" @reset="resetFn" @search="searchFn"
            @systemOrInstitutionChanged="systemOrInstitutionChanged" @recalculateTableHeight="recalculateTableHeight"
            @changeClear="changeClear" />
        </div>
        <!-- v-if="match_fail_count>0" -->
        <div ref="operateBtnHeight" class="operateBtn of" v-if="!imgShare">
          <div class="fl mt5 ml10 clr_red" style="cursor:pointer;">
            <i class="iconfont clr_red" style="font-size: 20px; cursor:pointer;">&#xe687;</i>
            <span @click="refreshTableForMatchFail" class="clr_red ml5" style="text-decoration: underline;">匹配失败：{{
              match_fail_count }} 条</span>

          </div>
          <div class="btnBox fr mb5 mt5 mr20" v-if="!imgShare">
            <el-form :disabled="!currentNodeAuth">


              <!--  互换？？？拆分？？  有拆分  就有互换 -->
              <el-button v-if="hasPerimission('yxcf')" @click="exchangeFn" type="primary" plain><i
                  class="iconfont mr5">&#xe6cb;</i>互换</el-button>
              <!-- <el-button v-if="hasPerimission('yxfs')" @click="sendImgFn" type="primary" plain class="ml10i"><i class="iconfont mr5">&#xe672;</i>转发</el-button> -->
              <el-button v-if="hasPerimission('yxpp')" @click="matchFn" type="primary" plain class="ml10i"><i
                  class="iconfont mr5">&#xe676a;</i>匹配</el-button>
              <el-button v-if="hasPerimission('yxfs')" @click="transpondFn" type="primary" plain class="ml10i"><i
                  class="iconfont mr5">&#xe6721;</i>转发</el-button>
              <el-button v-if="hasPerimission('yxdr')" @click="importImageFn" type="primary" plain
                class="ml10i shouldTransform"><i class="iconfont mr5">&#xe673;</i>导入</el-button>
              <!-- <el-button v-if="hasPerimission('yxdc')" @click="exportFn" type="primary" plain class="ml10i"><i class="iconfont mr5">&#xe673;</i>导出</el-button> -->
              <el-button v-if="hasPerimission('yxsc')" @click="deleteFn" type="danger" plain class="ml10i"><i
                  class="iconfont mr5">&#xe682;</i>删除</el-button>
              <!-- 回收站权限同删除权限 -->
              <el-button v-if="hasPerimission('yxsc')" :disabled="recycleTotal === 0" @click="recycleBinFn" type="primary"
                plain class="ml10i"><i class="iconfont mr5">&#xe86c;</i>回收站</el-button>
            </el-form>
          </div>
        </div>


        <el-table :data="tableData" border ref="mytable" :header-cell-style="{ background: '#F5F5F5', color: '#333' }"
          :height="tableHeighth" highlight-current-row @row-click="handleCurrentChange" @select="tableSignleSelection"
          @select-all="tableAllSelection" @selection-change="tableSelectionChange" @header-dragend="tableHeaderDragend"
          :row-key="getRowKey" header-row-class-name="strong">

      <el-table-column fixed="left" type="selection" :reserve-selection="true"></el-table-column>
      <el-table-column label="序" width="55" fixed="left" align="center">
        <template slot-scope="scope">
          {{ orderNum + 1 + scope.$index }}
        </template>
      </el-table-column>
      <el-table-column label="操作"  :width="operateWidth"  fixed="left">
        <template slot-scope="scope">
          <!--          <el-button title="查看" @click="toImgViewerPage(scope.row)" type="primary" size="small" class="w24 h24 lh24 nop"><i class="iconfont f18i thin">&#xe678;</i></el-button>-->
          <!--          <el-button v-if="hasPerimission('yxxg')" title="修改" @click="modifyFn(scope.row)" type="primary" size="small" class="w24 h24 lh24 nop"><i class="iconfont f18i thin">&#xe679;</i></el-button>-->
          <!--          <el-button v-if="hasPerimission('yxcf')" title="拆分" @click="splitFn(scope.row)" type="primary" size="small" class="w24 h24 lh24 nop"><i class="iconfont f18i thin">&#xe677;</i></el-button>-->
          <el-button @click="toImgViewerPage(scope.row)" type="text">查看</el-button>
          <ImgListTableOperateBtn v-if="!imgShare" class="fr" @singleMatchFn="singleMatchFn" @modifyFn="modifyFn"
            @splitFn="splitFn" @singleSendImg="singleSendImg" @singleDelete="singleDelete(scope.row)"
            @singleTranspondFn="singleTranspondFn" :ChosedRowItem="scope.row" />
        </template>
      </el-table-column>
      <el-table-column label="匹配状态" width="100" prop="match_state" align="center" fixed="left">
        <template slot-scope="scope">
          <div v-if="scope.row.match_state === 0">
            <i class="inline w10 h10 bg9 bradius5 mr6"></i>
            <span>未匹配</span>
          </div>
          <div v-if="scope.row.match_state === 10">
            <i class="inline w10 h10 bg_ef8900 bradius5 mr6"></i>
            <span>未摄片</span>
          </div>
          <div v-if="scope.row.match_state === 1">
            <i class="inline w10 h10 bg_49b523 bradius5 mr6"></i>
            <span>匹配成功</span>
          </div>
          <div v-if="scope.row.match_state === -1">
            <i class="inline w10 h10 bg_ff6f6f bradius5 mr6"></i>
            <span>匹配失败</span>
          </div>
        </template>
      </el-table-column>
      <!-- <el-table-column align="center">
        <template slot="header">
          <i @click="SetColumndShow = true" class="iconfont f20i clr_0a70b0">&#xe684;</i>
        </template>
      </el-table-column> -->
          <common-table :propData="propData"></common-table>
          <el-table-column fixed="right" align="right" width="50">
            <template slot="header">
              <span class="el-icon-s-tools" @click="SetColumndShow = true"></span>
            </template>
          </el-table-column>
        </el-table>
        <!-- 分页 -->
        <div ref="paginationHeight">
          <pagination-tool :total="total" :page.sync="listQuery.page_index" :limit.sync="listQuery.page_size"
            @pagination="fecthTableData" />
        </div>

        <div class="img_bshadow pt5 pl5 pr5 flex_row boxs" style="height:255px">
          <div v-if="seriesData.length !== 0" class="w160 h250 bg_f5 bradius5 mr15 flex_position flex_column"
            style="height: 210px; width: 140px;">
            <div class="w56 bbd pb22 mb22 tc">
              <p class="f18">序列数</p>
              <i class="f28">{{ series_count }}</i>
            </div>
            <div class="w56 tc">
              <p class="f18">实例数</p>
              <i class="f28">{{ images_count }}</i>
            </div>
          </div>
          <div class="col img_box">
            <div v-for="(item, index) in seriesData" :key="index" class="w180 f14 mr40 pb10 position_relative"
              @mouseenter="imgShow(item)" @mouseleave="imgHide(item)">
              <img v-show="item.isDelImgShow && hasPerimission('yxsc')" src="../../../assets/images/pacs/del_img.png"
                class="del_btn" @click="deleteSeries(item)" alt="">
              <el-image v-if="item.imgSrc" class="w180 h180" :src="item.imgSrc" fit="contain"
                @click="toImgViewerPage(currentRow)">
                <div slot="error" class="image-slot w100 h100 position_relative">
                  <i v-if="item.id" class="imgLoadFail position_absolute toCenter"></i>
                  <i v-else class="noImg position_absolute toCenter"></i>
                </div>
              </el-image>
              <el-image v-else class="w180 h180" fit="contain" src="noImg">
                <div slot="error" class="image-slot w100 h100 position_relative">
                  <i class="noImg position_absolute toCenter"></i>
                </div>
              </el-image>
              <div v-if="selectedSeries.includes(item)" class="position_absolute w180 h180 boxs otherDiv"
                style="border: 4px solid #1C8BE4;top: 0;height: 180px;"></div>
              <p class="mt5 mb5">序列编号：{{ item.series_number }}</p>
              <span>序列描述：{{ item.series_description }}</span>
              <el-checkbox v-if="!imgShare" v-model="selectedSeries" :label="item" class="position_absolute"
                style="top:0;right: 0;left: 0;bottom: 0;"><span></span></el-checkbox>
            </div>
          </div>
          <div class="btnBox mb5 mt5 mr20" v-if="!imgShare">
            <el-button v-show="selectedSeries.length > 0 && hasPerimission('yxsc')" @click="deleteMoreSeries"
              type="danger" plain class="ml10i" style="height: 30px;">删除</el-button>

          </div>
        </div>

      </div>
    </div>



    <!--  -->
    <!--    <detail-drawer :DrawerVisible="DrawerVisible" :rowItem="rowItem"/>-->



    <img-modify :imgModifyShow="imgModifyShow" :rowId="rowId" :dialogType="dialogType" @ImgModifyClose="ImgModifyClose"
      @refreshTable="getIMGList" />
    <!-- <send-img v-if="hasPerimission('yxfs')" :sendImgShow="sendImgShow" :sendImgData="sendImgData" @SendImgClose="SendImgClose"/> -->
    <exchange :exchangeShow="exchangeShow" :exchangeData="exchangeData" @ExchangeClose="ExchangeClose" />
    <transpond v-if="hasPerimission('yxfs')" :TranspondImgShow="TranspondImgShow" :TranspondDatas="TranspondDatas"
      @TranspondImgClose="TranspondImgClose"></transpond>
    <!--    <customized-list-->
    <!--      :customizedListShow="customizedListShow"-->
    <!--      :tableHeaderData="propData"-->
    <!--      @CustomizedListSave="CustomizedListSave"-->
    <!--      @CustomizedListClose="CustomizedListClose"/>-->
    <!--    <a href="/api/series/1262210573655871488/image" download="image.jpg">点我下载</a>-->
    <SetColumns :defaultColumn="defaultColumn" :SetColumndShow="SetColumndShow" @SetColumndBack="SetColumndBack"
      :owner="owner" />
    <ImportImage :dialogType="1" v-if="importDialogShow" :importDialogShow="importDialogShow"
      :systemsLiteList="systemsLiteList" :systemId="importSystemId" :institutionId="importInstitutionId"
      @importDialogClose="importDialogClose"></ImportImage>


    <!-- 影像级别的删除哦 -->
    <imgDeleteDialog v-if="delObj.show" :delObj="delObj" @delDialogClose="delDialogCloseFn"></imgDeleteDialog>

    <!-- 删除患者影像 -->
    <el-dialog v-el-drag-dialog v-if="delDailog" title="提示" :visible.sync="delDailog" width="580px" top="31vh"
      :before-close="handleClose">
      <div class="pt20">
        <div class="pb10" style="border-bottom: 1px dashed #cccccc;" v-if="delObj.match_state === 1">
          确认要<span class="clr_red strong f16">删除患者【{{ delObj.patient_name }}】</span>的<span
            class="clr_red strong f16">检查编号【{{ delObj.accession_number }}】</span>的影像吗
        </div>
        <div class="pb10" style="border-bottom: 1px dashed #cccccc;" v-else>确认要删除影像吗？</div>
        <div class="row space_between mt10">
          <div class="row">
            <p style="flex-shrink: 0;">账号：</p>
            <el-input style="width: 200px;" size="small" type="text" :disabled="true" v-model="profile.name"></el-input>
          </div>
          <div class="row">
            <p style="flex-shrink: 0;"><span class="f16 clr_red">*</span>密码：</p>
            <el-input style="width: 200px;" size="small" type="password" placeholder="请输入密码" clearable
              v-model="delPass"></el-input>
          </div>
        </div>
      </div>
      <span slot="footer" class="dialog-footer">
        <el-button size="small" @click="handleClose">取消</el-button>
        <el-button size="small" type="primary" @click="handleSure">确定</el-button>
      </span>
    </el-dialog>

    <!-- 导入文件 -->
    <!-- <el-dialog :append-to-body='true' :visible.sync="progressShow" :close-on-click-modal="false"
      :before-close="progressClose" :showClose="false" class="importDialog" width="500px" top="10%" center>
      <div slot="title" style="background-color: white;" class="pl20">
        正在导入
      </div>
      <div class="clear_fixed" style="height:100%;overflow-y: auto;margin-top: -7px;">
        <el-progress class="mb5 mt30 h30" :percentage="percentage"></el-progress>
        <div>文件数量（{{ didUploadFilesCount }}/{{ allFilesCount }}）</div>

      </div>
      <div slot="footer" class="dialog-footer clear_fixed">
        <el-button class="mr10 fr" @click="progressClose" size="medium">取 消</el-button>
      </div>

    </el-dialog> -->

    <!-- <input id="submitInput" type="file" @change="fileChange" ref="fileRef" webkitdirectory style="display: none;"> -->

    <el-dialog v-el-drag-dialog title="" :visible.sync="delingDailog" width="320px" :before-close="handleDelingClose"
      class="delingDialog">
      <div>
        <div class="mt10 mb10 f20"><i class=" icon iconTrans inline iconfont  clr_ef8900 ">&#xe821;</i> <span
            class="f16 clr_ef8900">影像删除中</span></div>
        <div class="f14 mb10">患者姓名：{{ delObj.patient_name }}</div>
        <div class="f14 mb10">检查编号：{{ delObj.accession_number }}</div>
      </div>
    </el-dialog>

  </div>
</template>
<script>
import Vue from 'vue'
import JSEncrypt from 'jsencrypt'
import HeadNav from "@/components/common/HeadNav"; // 头部导航
import HeadTabSwitch from '@/components/common/HeadTabSwitch' // 头部tab
import ConditionInquery from './components/ConditionInquery' // 查询条件
import CommonTable from '@/components/common/CommonTable' // 表格
import PaginationTool from '@/components/common/PaginationTool' // 分页
import { recalculateTableHeight } from '@/utils/mixin/filter' // 计算table 高度
import ImgModify from '@/components/pacs/commonDialog/ImgModify' // 影像修改 弹框
import SendImg from '@/components/pacs/commonDialog/SendImg' // 影像发送 弹框
import Transpond from '@/components/pacs/commonDialog/TranspondImg.vue'
import Exchange from '@/components/pacs/commonDialog/Exchange' // 交换
import imgDeleteDialog from './components/imgDeleteDialog.vue';
// import CustomizedList from '@/components/pacs/commonDialog/CustomizedList' // 自定义列表 弹框
import SetColumns from '@/components/pacs/commonDialog/SetColumns.vue' // 自定义列表 弹框
import ImgListTableOperateBtn from './components/imgListTableOperateBtn' // 更多
import ImportImage from './components/ImportImage.vue';
import moment from 'moment'
import { mapGetters } from 'vuex'
import Mgr from '@/utils/SecurityService'
import store from '@/store/index'
import { getConfigurations } from '@/api/Public.js'

export default {
  name: 'ImgList',
  data() {
    return {
      setObj:{},
      currentNodeAuth: true,//当前节点权限
      operateWidth:100,
      imgShare:false,
      BacsUrl: configUrl.frontEndUrl, // configUrl.frontEndUrl,,
      owner: 'archiveManage-studyList',
      SetColumndShow: false,
      TranspondImgShow: false,
      // TranspondData:'',
      tableHeight: 0,
      tableHeighth: "calc(100vh - 446px)",
      currentTableChecked: [], // 表格当中选中的行
      propData: [
        {
          prop: 'id',
          label: '检查主键',
          width: 100
        },
        {
          prop: 'other_patient_name',
          label: '患者姓名',
          width: 120,
          formatter: function (row) {
            let name = '';
            name = row.other_patient_name ? row.other_patient_name : row.patient_name;
            return name;
          }
        },
        {
          prop: 'patient_id',
          label: '患者编号',
          width: 160
        },
        {
          prop: 'patient_sex',
          label: '性别',
          width: 50,
          formatter: function (row) {
            const sexMapping = {
              M: '男',
              F: '女',
              O: '未知'
            }
            return sexMapping[row.patient_sex]
          }
        },
        {
          prop: 'patient_age',
          label: '年龄',
          width: 60,
          formatter: function (row) {
            const patient_ageTypeMapping = {
              'Y': '岁',
              'M': '月',
              'D': '日',
              'W': '周'
            }
            let patient_ageNum = ''
            let patient_ageType = ''
            if (row.patient_age) {
              patient_ageNum = row.patient_age.substring(0, row.patient_age.length - 1)
              patient_ageType = row.patient_age.substring(row.patient_age.length - 1, row.patient_age.length)
              return patient_ageNum + patient_ageTypeMapping[patient_ageType]
            } else {
              return ''
            }
          }
        },
        {
          prop: 'patient_birth_date',
          label: '出生日期',
          width: 160,
          formatter: function (row) {
            if (row.patient_birth_date) {
              return moment(row.patient_birth_date).format('YYYY-MM-DD')
            } else {
              return ''
            }
          }
        },
        {
          prop: 'exam_item',
          label: '检查项目',
          width: 130
        },
        {
          prop: 'modalities_in_study',
          label: '检查类型',
          width: 80
        },
        {
          prop: 'accession_number',
          label: '检查编号',
          width: 100
        },
        {
          prop: 'study_date_time',
          label: '检查时间',
          width: 160,
          formatter: function (row) {
            if (row.study_date_time) {
              return moment(row.study_date_time).format('YYYY-MM-DD HH:mm:ss')
            } else {
              return ''
            }
          }
        },
        {
          prop: 'study_description',
          label: '检查描述',
          width: 100
        },
        {
          prop: 'source_aet',
          label: '来源设备',
          width: 120
        },
        {
          prop: 'observation_room_name',
          label: '来源机房',
          width: 120
        },
        {
          prop: 'storage_state',
          label: '访问状态',
          width: 80,
          formatter: function (row) {
            if (row.storage_state === 0 || row.storage_state === -10) {
              return '在线'
            } else if (row.storage_state === 10) {
              return '近线'
            } else if (row.storage_state === 20) {
              return '远线'
            } else if (row.storage_state === -1) {
              return '离线'
            } else {
              return ''
            }
          }
        },
        {
          prop: 'volume_label',
          label: '备份标卷',
          width: 100
        },
        {
          prop: 'system_name',
          label: '系统名称',
          width: 100
        },
        {
          prop: 'institution_name',
          label: '机构名称',
          width: 100
        }
      ], // table表格原始表头数据
      tableData: [],
      defaultColumn: [
        { owner: 'archiveManage-studyList', field_code: 'id', field_name: '检查主键', column_width: 100, essential: 1, visibility: 1, fixed: 0, sort: 1 },
        { owner: 'archiveManage-studyList', field_code: 'patient_name', field_name: '患者姓名', column_width: 120, essential: 1, visibility: 1, fixed: 0, sort: 2 },
        { owner: 'archiveManage-studyList', field_code: 'patient_id', field_name: '患者编号', column_width: 160, essential: 1, visibility: 1, fixed: 0, sort: 3 },
        { owner: 'archiveManage-studyList', field_code: 'patient_sex', field_name: '性别', column_width: 50, essential: 1, visibility: 1, fixed: 0, sort: 4 },
        { owner: 'archiveManage-studyList', field_code: 'patient_age', field_name: '年龄', column_width: 60, essential: 1, visibility: 1, fixed: 0, sort: 5 },
        { owner: 'archiveManage-studyList', field_code: 'patient_birth_date', field_name: '出生日期', column_width: 160, essential: 1, visibility: 1, fixed: 0, sort: 6 },
        { owner: 'archiveManage-studyList', field_code: 'exam_item', field_name: '检查项目', column_width: 130, essential: 1, visibility: 1, fixed: 0, sort: 7 },
        { owner: 'archiveManage-studyList', field_code: 'modalities_in_study', field_name: '检查类型', column_width: 80, essential: 1, visibility: 1, fixed: 0, sort: 8 },
        { owner: 'archiveManage-studyList', field_code: 'accession_number', field_name: '检查编号', column_width: 100, essential: 1, visibility: 1, fixed: 0, sort: 9 },
        { owner: 'archiveManage-studyList', field_code: 'study_date_time', field_name: '检查时间', column_width: 160, essential: 1, visibility: 1, fixed: 0, sort: 10 },
        { owner: 'archiveManage-studyList', field_code: 'study_description', field_name: '检查描述', column_width: 100, essential: 1, visibility: 1, fixed: 0, sort: 11 },
        { owner: 'archiveManage-studyList', field_code: 'source_aet', field_name: '来源设备', column_width: 120, essential: 1, visibility: 1, fixed: 0, sort: 12 },
        { owner: 'archiveManage-studyList', field_code: 'observation_room_name', field_name: '来源机房', column_width: 120, essential: 1, visibility: 1, fixed: 0, sort: 13 },
        { owner: 'archiveManage-studyList', field_code: 'storage_state', field_name: '访问状态', column_width: 80, essential: 1, visibility: 1, fixed: 0, sort: 14 },
        { owner: 'archiveManage-studyList', field_code: 'volume_label', field_name: '备份标卷', column_width: 100, essential: 1, visibility: 1, fixed: 0, sort: 15 },
        { owner: 'archiveManage-studyList', field_code: 'system_name', field_name: '系统名称', column_width: 100, essential: 1, visibility: 1, fixed: 0, sort: 16 },
        { owner: 'archiveManage-studyList', field_code: 'institution_name', field_name: '机构名称', column_width: 100, essential: 1, visibility: 1, fixed: 0, sort: 17 },
        { owner: 'archiveManage-studyList', field_code: 'storage_device_name', field_name: '存储设备', column_width: 150, essential: 1, visibility: 0, fixed: 0, sort: 18 },
        { owner: 'archiveManage-studyList', field_code: 'relative_path', field_name: '存储路径', column_width: 180, essential: 1, visibility: 0, fixed: 0, sort: 19 },

        //
      ],
      importDialogShow: false,
      // allFilesCount: 0,
      // didUploadFilesCount: 0,
      // progressShow: false,
      imgModifyShow: false,
      sendImgShow: false,
      exchangeShow: false,
      TranspondDatas: [],//要转发的数据
      sendImgData: [], // 要发送的数据
      exchangeData: [], // 要交换的数据
      // customizedListShow: false,
      // currentRightCheckedData: [], // 当前自定义列表显示内容
      listQuery: {
        page_index: 1,
        page_size: 10
      },
      formData: { match_state: '' },
      total: 10000,
      recycleTotal: 0,
      rowId: 0,
      dialogType: '', // 弹窗的类型: 查看view 修改modify
      currentRow: null, // 表格当前点击的行
      series_count: 0, // 序列数
      images_count: 0, // 实例数
      seriesData: [],
      baseUrl: '',
      SystemId: '',
      InstitutionId: '',
      pathUrl: '',
      systemsLiteList: [], // 系统名称
      accession_number: '',
      study_instance_uid: '',
      delingDailog: false,
      delDailog: false,
      delPass: '',
      delId: '',
      delObj: {
        show: false,
      },
      profile: {
        name: ''
      },
      delSeqObjs: [],
      currentSystemClass: '',
      ObservationRoomIds: [],
      selectedSeries: [],
      match_fail_count: 0,
      clear_select: false,
      importSystemId: '',
      importInstitutionId: '',
      defaultSystemAndInstitutionId: {
        systemId: '',
        institutionId: '',
      },
      nodeList: [],
    }
  },
  mixins: [recalculateTableHeight],
  mounted() {

    this.setObj = JSON.parse(localStorage.getItem('setObj')) || JSON.parse(localStorage.getItem('setPacsObj')) || {}
    this.getDefaultSystemIdAndInstitutionId()
    this.currentSystemClass = sessionStorage.getItem('currentSystemClass') || ''
    this.profile = JSON.parse(this.loginInfo)?.profile
    this.pathUrl = process.env.NODE_ENV === 'development' ? '' : '/paservice'
    this.baseUrl = process.env.NODE_ENV === 'development' ? 'http://www.eworlds.com.cn' : configUrl.frontEndUrl

    if (this.$route.query?.just_look) {
      this.imgShare = this.$route.query?.just_look == 'true'
      if (this.imgShare) this.operateWidth = 55
    }

    if (this.$route.query.institution_id) {
      store.commit('permission/SET_DEPTINSTITUTIONID', this.$route.query.institution_id)
    }

    console.log('传参11', this.$route.query);
    if (this.$route.query.institution_id ||
      this.$route.query.param_value
      || this.$route.query.start_doubleScreen) {
      let setObjFromSystem = {
        GeneralCliParameter_WorkInstitutionId: this.$route.query.institution_id,
        param_value: this.$route.query.param_value,
        start_doubleScreen: this.$route.query.start_doubleScreen,
      }

      window.localStorage.setItem('setObj', JSON.stringify(setObjFromSystem))
    }

    if (this.$route.query.ObservationRoomIds) {
      this.ObservationRoomIds = JSON.parse(this.$route.query.ObservationRoomIds)
    }

    if (this.$route.query?.showMatchFailed) {
      this.formData.match_state = -1
    }
    if (this.scope && this.scope === 'institution' && this.systemid) {
      // 本地取得institution
      // this.getUserInfo()
      this.SystemId = this.systemid
      this.InstitutionId = this.deptInstitutionId
    } else if (this.scope && this.scope === 'system' && this.systemid) {
      this.SystemId = this.systemid
    }
    if(this.imgShare){
      this.SystemId = this.$route?.query?.systemid
      this.InstitutionId = this.$route?.query?.institution_id

    }
    // this.currentRightCheckedData = this.propData // 复制一份
    if (this.currentSystemClass === 'NMIS' || this.currentSystemClass === 'RTIS') {
      this.propData = [...this.defaultColumn.map(e => ({ ...e, prop: e.field_code, label: e.field_name, width: e.column_width }))]
    } else {
      this.getColumnCustom()
    }
    console.log('当前节点type是', this.currentNodeType);
    console.log('当前样式为', this.cardStyle);
    if (this.currentNodeType == 'converge') {
      this.getArchiveNodeList()//获取节点列表
    }

    this.getSystemsLiteList() // 获取系统名称
    this.getConfigurationsFn()

    this.importSystemId = this.SystemId
    this.importInstitutionId = this.InstitutionId

    // window.onresize(()=>{
    // })
    this.$nextTick(()=>{
      this.updateTableHeight()
    })

  },

  created() {
    let height = 563

    if (this.group === 'tenancy') {
      height = 563
      this.tableHeighth = 'calc(100vh - 563px)'
    } else {
      height = 520
      this.tableHeighth = 'calc(100vh - 520px)'
    }
    if (this.imgShare) {
      if (height == 563) {
        this.tableHeighth = 'calc(100vh - 448px)'

      } else {
        this.tableHeighth = 'calc(100vh - 400px)'

      }


    }
  },
  computed: {
    orderNum() {
      if (this.listQuery.page_index === 1) {
        return 0
      } else {
        return (this.listQuery.page_index - 1) * this.listQuery.page_size
      }
    },
    ...mapGetters(['group', 'permissions', 'permissionsMapping', 'systemid', 'scope', 'deptInstitutionId', 'exchangeState', 'currentNodeType', 'cardStyle','loginInfo'])
  },
  watch: {
    // $route: {
    //   handler: function (newVal) {
    //     console.log(newVal)
    //     if(newVal.query['match_state'] && newVal.query['match_state'] === '0') {
    //       this.formData.match_state = 0
    //     }else {
    //       this.formData.match_state = ''
    //     }
    //     if(newVal.path === '/IMGLIST') {
    //       this.getIMGList()
    //     }
    //   },
    //   deep: true,
    //   immediate: true
    // },
    $route: {
      handler: function (newVal) {
        // console.log(newVal)
        if (newVal.query['match_state'] && newVal.query['match_state'] === '1') {
          let model = this.tableData.find(e => e.id === this.rowId)
          if (model !== undefined) {
            model.match_state = 1
          }
        } else {
        }
      },
      deep: true,
      immediate: true
    },
    // tableData :{
    //   handler : function (newVal){
    //     console.log('没有变化吗？');
    //     if(newVal){
    //       this.match_fail_count = newVal.filter(e=>e.match_state == '-1').length
    //     }
    //   },
    //   deep:true,
    //   immediate:true,
    // },
    exchangeState(val) {
      if (val) {
        this.getIMGList()
        this.getMatchFailCount()
      }
    }
  },
  methods: {
    updateTableHeight(){
      let height = this.$refs.condationHeight.offsetHeight +
      this.$refs.operateBtnHeight.offsetHeight +
      this.$refs.paginationHeight.offsetHeight + 255 + 117
      // if(this.group != 'tenancy'){
      //   height = height - 50
      // }
    this.tableHeighth = `calc(100vh - ${height}px)`
    },
    getRowKey(row) {
      return row.id
    },
    imgShow(item) {
      if (this.imgShare) return false
      item.isDelImgShow = true;
    },
    imgHide(item) {
      item.isDelImgShow = false;
    },
    // 是否有权限
    hasPerimission(permissionName) {
      if (this.group === 'tenancy') {
        return true
      }
      return this.permissions.includes(permissionName)
    },
    // 获取用户信息
    async getUserInfo() {
      let res = JSON.parse(this.loginInfo);
      if (!res) {
        const manager = new Mgr()
        res = await manager.getRole()
      }
      if (res) {
        this.InstitutionId = res.profile.inst_id
      }
    },
    deleteSeries(item) {

      this.delObj = this.currentRow
      this.delPass = ''
      this.delId = item.id
      this.delDailog = true
      this.delSeqObjs = [item]
      // console.log(item, this.currentRow);
      // this.$confirm('是否确认删除当前序列？', {
      //   confirmButtonText: '确定',
      //   cancelButtonText: '取消',
      //   type: 'warning'
      // }).then(() => {
      //   this.deleteSeriesFun(item)
      // }).catch(() => {
      //   this.$message({
      //     type: 'info',
      //     message: '已取消删除'
      //   })
      // })
    },

    deleteMoreSeries() {
      this.delObj = this.currentRow

      this.delSeqObjs = this.selectedSeries;
      this.delPass = ''
      this.delDailog = true

    },



    async deleteStudySeriesImgsFun(params) {
      this.delingDailog = true;
      //支持删除多个
      let [res, err] = await this.$pacsApi.pacsApi.deleteSeries(params);
      this.delingDailog = false;
      if (err) {
        this.delingDailog = false;
        return
      }
      this.delingDailog = false;
      let { code, msg } = res;
      if (code === 0) {
        this.$message({
          type: 'success',
          message: msg
        })
        // console.log('我没有更新吗？');
        this.getIMGList();
        this.getRecycledIMGList()
        this.getMatchFailCount();
        if (this.currentRow) {
          this.getSeriesInfo(this.currentRow.id);
          this.handleCurrentChange(this.currentRow);
        }

        this.delSeqObjs = []
      }
    },

    async deleteSeriesFun(item) {
      this.delingDailog = true;


      //支持删除多个
      let series_delete_dtos = item.map(e => ({ "series_instance_uid": e.series_instance_uid }));
      const params = {
        "delete_type": 1,
        "accession_number": this.accession_number,
        "study_instance_uid": this.study_instance_uid,
        series_delete_dtos,
        // "series_delete_dtos": [{
        //   "series_instance_uid": item.series_instance_uid
        // }]
      };
      let [res, err] = await this.$pacsApi.pacsApi.deleteSeries(params);
      this.delingDailog = false;

      if (err) {
        this.delingDailog = false;
        return
      }
      this.delingDailog = false;
      let { code, msg } = res;
      if (code === 0) {
        this.$message({
          type: 'success',
          message: msg
        })
        this.getIMGList();
        this.getRecycledIMGList()
        this.getMatchFailCount();
        if(this.currentRow)
        {
          this.getSeriesInfo(this.currentRow.id);
        this.handleCurrentChange(this.currentRow);
        }
     
        this.delSeqObjs = []
      }
    },
    SetColumndBack(val) {
      this.$refs.mytable.doLayout()

      this.SetColumndShow = false
      if (val) {
        this.getColumnCustom()
      }
    },
    // 获取自定义列
    getColumnCustom() {
      var _this = this
      var data = {
        owner: _this.owner,
        platformService: 4
      }
      _this.$pacsApi.pacsApi.getColumnCustom(data).then(res => {
        var Arr = []
        var NewArr = []
        if (res.code === 0) {
          Arr = res.data.length === 0 ? this.defaultColumn : res.data
          let sortArr = Arr.sort((a, b) => {
            return a.sort - b.sort
          })
          sortArr.forEach(item => {
            if (item.visibility) {
              item.prop = item.field_code
              item.label = item.field_name
              item.width = item.column_width
              if (item.field_code === 'patient_sex') {
                item.formatter = function (row) {
                  const sexMapping = {
                    M: '男',
                    F: '女',
                    O: '未知'
                  }
                  return sexMapping[row.patient_sex]
                }
              } else if (item.field_code === 'patient_age') {
                item.formatter = function (row) {
                  const patient_ageTypeMapping = {
                    'Y': '岁',
                    'M': '月',
                    'D': '日',
                    'W': '周'
                  }
                  let patient_ageNum = ''
                  let patient_ageType = ''
                  if (row.patient_age) {
                    patient_ageNum = row.patient_age.substring(0, row.patient_age.length - 1)
                    patient_ageType = row.patient_age.substring(row.patient_age.length - 1, row.patient_age.length)
                    return patient_ageNum + patient_ageTypeMapping[patient_ageType]
                  } else {
                    return ''
                  }
                }
              } else if (item.field_code === 'patient_birth_date') {
                item.formatter = function (row) {
                  if (row.patient_birth_date) {
                    return moment(row.patient_birth_date).format('YYYY-MM-DD')
                  } else {
                    return ''
                  }
                }
              } else if (item.field_code === 'study_date_time') {
                item.formatter = function (row) {
                  if (row.study_date_time) {
                    return moment(row.study_date_time).format('YYYY-MM-DD HH:mm:ss')
                  } else {
                    return ''
                  }
                }
              } else if (item.field_code === 'storage_state') {
                item.formatter = function (row) {
                  if (row.storage_state === 0 || row.storage_state === -10) {
                    return '在线'
                  } else if (row.storage_state === 10) {
                    return '近线'
                  } else if (row.storage_state === 20) {
                    return '远线'
                  } else if (row.storage_state === -1) {
                    return '离线'
                  } else {
                    return ''
                  }
                }
              }
              NewArr.push(item)
            }
          })
          _this.propData = NewArr
          // _this.getIMGList()
        } else {
          _this.$message.error(res.msg)
        }
      })
    },
    ImgModifyClose() {
      this.imgModifyShow = false
      this.closeSession()
    },
    SendImgClose() {
      this.sendImgShow = false
      this.closeSession()
    },
    ExchangeClose() {
      this.exchangeShow = false
      this.closeSession()
    },
    TranspondImgClose() {
      this.TranspondImgShow = false
      this.closeSession()
    },
    closeSession() {
      this.currentTableChecked = []
      this.$nextTick(() => {
        this.$refs.mytable.clearSelection()
      })
    },
    // CustomizedListClose () {
    //   this.customizedListShow = false
    // },
    // CustomizedListSave (currentRightChcked) {
    //   const currentRightChckedData = []
    //   currentRightChcked.forEach(ele => {
    //     this.propData.forEach(item => {
    //       if (item.prop === ele) {
    //         currentRightChckedData.push(item)
    //       }
    //     })
    //   })
    //   // 自定义列表保存之后,改变table表头信息
    //   this.currentRightCheckedData = currentRightChckedData
    //   this.customizedListShow = false
    // },
    // 单条匹配
    singleMatchFn(rowData) {

      //单独匹配---支持匹配成功、未匹配
      let params = [rowData]
      this.rowId = rowData.id
      params = JSON.stringify([rowData])
      this.$router.push({ path: this.pathUrl + '/DataManagement/matching', query: { singleMatch: rowData.match_state !== -1, waitMatchData: params, group: this.group, systemid: this.$route.query.systemid } })
    },
    matchFn() {

      //只能匹配  匹配失败的数据吗？

      let hasUnMatch = this.currentTableChecked.some((ele) => { //match_state
        return ele.match_state !== -1 // 匹配失败
      })
      if (hasUnMatch) {
        this.$message({
          showClose: true,
          message: '只能对匹配失败的影像进行批量匹配',
          type: 'warning'
        })
        return
      }

      let params = this.currentTableChecked
      params = JSON.stringify(this.currentTableChecked)
      this.$router.push({ path: this.pathUrl + '/DataManagement/matching', query: { group: this.group, systemid: this.$route.query.systemid, waitMatchData: params } })
    },

    importDialogClose() {

      this.importDialogShow = false

    },

    importImageFn() {
      // debugger
      this.importDialogShow = true


    },

    reImportImage() {
      this.importDialogShow = false
      this.uploadingImage(this.failFileList)

    },

    singleTranspondFn(rowData) {

      // this.currentTableChecked = rowData
      this.TranspondDatas = [rowData]
      this.TranspondImgShow = true

    },
    transpondFn() {

      if (this.currentTableChecked.length === 0) {
        this.$message({
          showClose: true,
          message: '请选择要发送的内容',
          type: 'warning'
        })
        return
      }
      this.TranspondDatas = [...this.currentTableChecked]
      this.TranspondImgShow = true
    },
    deleteFn() {

      if (this.currentTableChecked.length === 0) {
        this.$message({
          showClose: true,
          message: '请选择要删除的内容',
          type: 'warning'
        })
        return
      } else if (this.currentTableChecked.length > 1) {
        this.$message({
          showClose: true,
          message: '一次只能删除一条内容',
          type: 'warning'
        })
        return
      }
      this.delObj.data = this.currentTableChecked[0]
      this.delObj.show = true


      //=============
      // this.delPass = ''
      // this.delId = this.currentTableChecked[0].id
      // this.delObj = this.currentTableChecked[0]
      // this.delDailog = true
    },
    delDialogCloseFn(type, params) {
      //删除弹框关闭
      this.delObj.show = false
      if (type == 'confirm' && params) {
        //
        console.log('先测试流程哦', params);
        this.deleteStudySeriesImgsFun(params)

      }
    },
    recycleBinFn() {
      this.$router.push({ path: this.pathUrl + '/DataManagement/recyclebin', query: { group: this.group, systemid: this.$route.query.systemid } })

    },
    async handleSure() {
      const params = {
        user_name: this.profile.phone_number,
        password: this.$getRsaCode(this.delPass)
      }

      const res = await this.$pacsApi.pacsApi.checkPassword(params)
      if (res.code === 0) {
        this.closeSession()
        if (this.delSeqObjs.length) {
          this.deleteSeriesFun(this.delSeqObjs)
        } else {
          this.deleteImg()
        }
        this.delDailog = false
      } else {
        this.$message.error(res.msg)
      }
    },
    handleDelingClose() {
      this.delingDailog = false;
    },
    handleClose() {
      this.delDailog = false
      this.delSeqObjs = []
    },
    async getConfigurationsFn() {
      const res = await getConfigurations('TransmissionSecurity.RSA.PublicKey')
      if (res.code === 0) {
        // rsa加密
        Vue.prototype.$getRsaCode = function (str) { // 注册方法
          const pubKey = res.data// ES6 模板字符串 引用 rsa 公钥
          const encryptStr = new JSEncrypt()
          encryptStr.setPublicKey(pubKey) // 设置 加密公钥
          const data = encryptStr.encrypt(str.toString()) // 进行加密
          return data
        }
      }
    },
    async deleteImg() {
      this.delingDailog = true;
      let [res, err] = await this.$pacsApi.pacsApi.deleteImg(this.delId)
      if (err) {
        this.delingDailog = false;
        return;
      }

      let { code, msg } = res
      this.delingDailog = false;

      if (code === 0) {
        this.$message({
          type: 'success',
          message: msg
        })
        this.refreshTableFn()
      } else {
        this.$message.error(res.msg)
      }
    },
    refreshTableFn() {
      this.getIMGList();
      this.getRecycledIMGList()
      this.getMatchFailCount();
      this.series_count = 0;
      this.images_count = 0;
      this.seriesData = [];
    },
    // 单个删除
    singleDelete(row) {

      this.delObj.data = row
      this.delObj.show = true
      //====
      // this.delPass = ''
      // this.delId = row.id
      // this.delObj = row
      // this.delDailog = true

    },
    changeClear() {
      this.clear_select = false
    },
    refreshTableForMatchFail() {
      this.formData.match_state = -1
      this.clear_select = true
    },


    getDefaultSystemIdAndInstitutionId() {

      const permissionArr = JSON.parse(sessionStorage.getItem('permissionArr')) || []
      this.jgyxlbPermission = permissionArr.some(o => o.code === 'ris_jgyxlb') // 机构
      this.ksyxlbPermission = permissionArr.some(o => o.code === 'ris_ksyxlb') // 系统
      // console.log('当前用户角色以及权限', this.group, this.jgyxlbPermission, this.ksyxlbPermission);
      if (this.group === "dept") {
        // 科室角色
        this.defaultSystemAndInstitutionId.systemId = this.systemid;
        const setObj = this.setObj
        // JSON.parse(localStorage.getItem('setObj')) || JSON.parse(localStorage.getItem('setPacsObj')) || {}
        if (!this.ksyxlbPermission && this.jgyxlbPermission && setObj?.GeneralCliParameter_WorkInstitutionId) {
          this.defaultSystemAndInstitutionId.institutionId = setObj.GeneralCliParameter_WorkInstitutionId

        } else {
          this.defaultSystemAndInstitutionId.institutionId = null
        }

      } else if (this.group === "doct") {
        this.defaultSystemAndInstitutionId.systemId = this.systemid;
        this.defaultSystemAndInstitutionId.institutionId = this.deptInstitutionId;

      }

    },
    //获取匹配失败总数
    async getMatchFailCount() {
      const data = {}
      data.system_id = this.SystemId ? this.SystemId : this.defaultSystemAndInstitutionId.systemId
      data.institution_id = this.InstitutionId ? this.InstitutionId : this.defaultSystemAndInstitutionId.institutionId
      data.match_state = '-1'
      this.$pacsApi.pacsApi.getIMGList(data).then(res => {
        const { code, data, page } = res
        if (code === 0) {
          this.match_fail_count = page.total_count
        }
      })
    },
    async getRecycledIMGList() { // 获取回收站列表
      const data = {}
      let self = this
      data.system_id = this.SystemId ? this.SystemId : this.formData.system_id
      data.institution_id = this.InstitutionId ? this.InstitutionId : this.formData.institution_id
      this.$pacsApi.pacsApi.getRecycledIMGList(data).then(res => {
        const { code, data, page } = res
        if (code === 0) {
          self.recycleTotal = page.total_count
        }
      })

    },
    async getIMGList() { // 获取列表
      const data = Object.assign(this.formData, this.listQuery)
      data.system_id = this.SystemId ? this.SystemId : this.formData.system_id
      data.institution_id = this.InstitutionId ? this.InstitutionId : this.formData.institution_id
      this.$pacsApi.pacsApi.getIMGList(data).then(res => {
        const { code, data, page } = res
        if (code === 0) {
          this.tableData = data
          this.total = page.total_count
          this.$refs.mytable.doLayout()
        }
      })

    },
    async fecthTableData() { // 翻页改变
      this.tableData = []
      this.getIMGList()
    },
    systemOrInstitutionChanged(params) {
      //搜索条件发生变化
      //主要关注系统以及机构变化==>导入影像
      this.importSystemId = params.system_id
      this.importInstitutionId = params.institution_id


    },
    resetFn() {
      this.$nextTick(() => {
        this.$refs.mytable.clearSelection()

      })
    },
    searchFn(params) { // 搜素

      console.log('默认搜索参数list', params);
      this.listQuery.page_index = 1 // 重置页数
      this.formData = params
      this.getIMGList()
      if (!this.imgShare) {
        this.getMatchFailCount()
        this.getRecycledIMGList()
      }
      this.series_count = 0
      this.images_count = 0
      this.seriesData = []

      this.importSystemId = params.system_id
      this.importInstitutionId = params.institution_id

    },
    setMatchState(val) {

      this.formData.match_state = val

    },
    async getSeriesImg(id) {
      let fileRes = await this.$pacsApi.pacsApi.getSeriesImg(id)
      let blobData = new Blob([fileRes])
      let imgUrl = URL.createObjectURL(blobData)
      // console.log(imgUrl)
      return imgUrl
    },
    async getSeriesInfo(id) {
      this.seriesData = []
      let res = await this.$pacsApi.pacsApi.getSeriesInfo(id)
      let { code, data } = res
      if (code === 0) {
        if (data.length === 0) {
          this.series_count = 0
          this.images_count = 0
          this.seriesData = []
        } else {
          this.series_count = data.length
          this.images_count = data.reduce((totalVal, currentVal) => {
            return totalVal + currentVal.images_count
          }, 0)
          let readerPromise = (fileRes) => {
            return new Promise((resolve, reject) => {
              let reader = new FileReader()
              reader.readAsDataURL(fileRes)
              reader.onload = () => {
                // console.log(reader.result)
                resolve(reader.result)
              }
            })
          }
          // data.forEach(async (ele, index) => {
          // let fileRes = await this.$pacsApi.pacsApi.getSeriesImg(ele.id)
          // let blobData = new Blob([fileRes])
          // let imgUrl = URL.createObjectURL(blobData)
          // this.$set(data[index], 'imgSrc', imgUrl)

          // let fileRes = await this.$pacsApi.pacsApi.getSeriesImg(ele.id)
          // let readerResult = await readerPromise(fileRes)
          // console.log(readerResult)
          // this.$set(data[index], 'imgSrc', readerResult)
          // let reader = new FileReader()
          // reader.readAsDataURL(fileRes)
          // reader.onload = () => {
          //   console.log(reader.result)
          //   this.$set(data[index], 'imgSrc', reader.result)
          // }
          // });
          let forFn = async () => {
            for (let i = 0; i < data.length; i++) {
              let fileRes = await this.$pacsApi.pacsApi.getSeriesImg(data[i]['id'])
              let readerResult = await readerPromise(fileRes)
              // console.log(readerResult)
              this.$set(data[i], 'imgSrc', readerResult)
            }
          }
          forFn()
          data.forEach(item => {
            item.isDelImgShow = false;
          });
          this.seriesData = data;
          this.$forceUpdate();
        }
      }
    },
    // 表格操作
    handleCurrentChange(val) {
      this.selectedSeries = []
      this.currentRow = val
      // 获取序列信息
      if (this.currentRow) {
        this.getSeriesInfo(this.currentRow.id)
        this.accession_number = this.currentRow.accession_number;
        this.study_instance_uid = this.currentRow.study_instance_uid;
      }
    },
    tableSignleSelection(rows, row) {
      // console.log("重新点击",rows);
      this.currentTableChecked = rows
    },
    tableAllSelection(rows) {
      this.currentTableChecked = rows

    },
    tableSelectionChange(rows) {
      // if (rows.length === 0 && this.currentTableChecked.length !== 0) {
      //   // console.log('说明有弹框清空了数据');
      //   this.currentTableChecked = []
      // }
      // const arr = []
      // this.tableData.forEach(item => {
      //   let fil = currentTableChecked.filter(val => item.id === val.id)
      //   if (fil.length) {
      //     arr.push(item)
      //   }
      // })
      // this.currentTableChecked = arr
      // console.log(this.currentTableChecked);
    },
    tableHeaderDragend() {
      this.$refs.mytable.doLayout()
    },
    async getViewerKey(id) {
      let res = await this.$pacsApi.pacsApi.getViewerKey(id)
      let { code, data } = res
      if (code === 0) {
        window.open(this.baseUrl + '/s/' + data)
      }
    },
    postOpenWindow(URL, PARAMS, target) {
      var temp_form = document.createElement('form')
      temp_form.action = URL
      temp_form.target = target
      temp_form.method = 'post'
      temp_form.style.display = 'none'
      for (var x in PARAMS) {
        var opt = document.createElement('textarea')
        opt.id = x
        opt.innerHTML = PARAMS[x]
        temp_form.appendChild(opt)
      }
      document.body.appendChild(temp_form)
      temp_form.submit()
      alert(document.getElementsById('href'))
      document.body.removeChild(temp_form)
    },
    async getViewUrl(rowData) {
      // console.log(rowData)
      var _this = this
      var newArr = []
      newArr.push(rowData.id)
      let usee_world_view = (this.setObj&&this.setObj.param_value) || false
      let StartDoubleScreen = (this.setObj.start_doubleScreen&&this.this.setObj) || false
      // 启用双屏插件
      var data = {
        study_ids: newArr,
        usee_world_view: usee_world_view
      }
      this.$pacsApi.pacsApi.getViewUrl(data).then(res => {
        if (res.code === 0) {
          if (!usee_world_view && StartDoubleScreen) { // 启用双屏
            // var data = {
            //   performed_procedure_ids: newArr,
            //   UseeWorldView: UseeWorldView
            // }
            const title = rowData.patient_name + '-' + rowData.patient_sex + '-' + rowData.patient_age + '-' + row.modalities_in_study
            const url = _this.BacsUrl + '/s/' + res.data
            const doubleURL = this.BacsUrl + '/s' + res.data + '||:' + title
            var manager = new Mgr()
            manager.getRole().then(function (logindata) {
              if (process.env.NODE_ENV === 'development') {
                _this.postOpenWindow('eworldimageview:\\' + doubleURL, '_blank')
                // window.open('eworldimageview:\\' + _this.BacsUrl + '/eworldimageview.html?href=' + res.data + '&Token=' + encodeURI(JSON.stringify(Token)))
              } else {
                _this.postOpenWindow('eworldimageview:\\' + doubleURL, '_blank')
                // window.open('eworldimageview:\\' + _this.BacsUrl + '/cloudpacs/eworldimageview.html?href=' + res.data + '&Token=' + encodeURI(JSON.stringify(Token)))
              }
            })
          } else if (usee_world_view) {
            window.open(res.data)
          } else {
            window.open(configUrl.frontEndUrl + '/s/' + res.data)
          }
        } else {
          this.$message.error(res.msg)
        }
      })
    },
    toImgViewerPage(rowData) {
      this.getViewUrl(rowData)
    },
    // viewDetail (rowData) { // 查看
    //   this.rowId = rowData.id
    //   this.dialogType = 'view'
    //   this.imgModifyShow = true
    // },
    modifyFn(rowData) { // 修改
      this.rowId = rowData.id
      this.dialogType = 'modify'
      this.imgModifyShow = true
      // this.getSeriesImg('1262210573655871488')
    },
    splitFn(rowData) { // 拆分
     
      // 兼容  ---外部传参字段  
      let numbers = [rowData.accession_number]
      // numbers = [rowData.accession_number,'XCT024019','XCT024018','LCT000722']
      this.$router.push({ path: this.pathUrl + '/DataManagement/splitting', query: { number_id: rowData.id, accession_numbers: numbers, group: this.group, systemid: this.$route.query.systemid } })
    },
    exportFn() { // 导出
      if (this.currentTableChecked.length === 0) {
        this.$message({
          showClose: true,
          message: '请选择要导出的内容',
          type: 'warning'
        })
        return
      }
      const h = this.$createElement
      this.$msgbox({
        message: h('div', { style: 'padding: 30px 35px 25px 60px' }, [
          h('div', { style: 'height: 20px; line-height: 20px;' }, [
            h('i', { class: 'iconfont', style: 'color: #EF8900;font-size:18px;margin-right: 11px;vertical-align: middle;' }, '\ue687'),
            // h('a', { ref: 'exportFile', attrs: { href: '', download: 'hello.png' } }, '点击导出'),
            h('a', { on: { click: this.exportImg }, style: 'cursor: pointer;' }, '点击导出')
          ])
        ]),
        showCancelButton: true,
        // confirmButtonText: '确定',
        cancelButtonText: '关闭'
      }).catch(action => {
        // this.$message({
        //   type: 'info',
        //   message: '已取消导出'
        // })
      });
      // this.$nextTick(() => {
      //   this.$refs.exportFile.href = '../../assets/images/logo.png'
      // })
    },
    async exportImg() {
      let idArr = this.currentTableChecked.map(ele => ele['id'])
      let res = await this.$pacsApi.pacsApi.exportImg(idArr)
      let { code, data } = res
      if (code === 0) {
        this.closeSession()
        // console.log(data)
      }
    },
    // 单条转发
    singleSendImg(rowData) {

      this.sendImgData = [rowData]
      this.sendImgShow = true
    },
    sendImgFn() { // 转发

      if (this.currentTableChecked.length === 0) {
        this.$message({
          showClose: true,
          message: '请选择要发送的内容',
          type: 'warning'
        })
        return
      }
      this.sendImgData = [...this.currentTableChecked]
      this.sendImgShow = true
      // console.log(this.currentTableChecked)
    },
    async getSystemsLiteList() {
      let res = await this.$pacsApi.pacsApi.getSystemsLiteList({ type: 1 })
      let { code, data } = res
      if (code === 0) {
        this.systemsLiteList = data
      }
    },
    async getArchiveNodeList() {
      const [res, err] = await this.$pacsApi.pacsApi.getArchiveNodeList();
      // debugger
      if (res) {
        this.nodeList = res.data
      }
    },
    // 交换
    exchangeFn() {
      // console.log(this.currentTableChecked)
      if (this.currentTableChecked.length < 2) {
        this.$message({
          showClose: true,
          message: '请选择2条要交换的内容',
          type: 'warning'
        })

      } else if (this.currentTableChecked.length > 2) {
        this.$message({
          showClose: true,
          message: '所选记录超过2条，只能对2条记录进行交换',
          type: 'warning'
        })

      } else {
        this.$store.commit('imgExchange/SET_FINALY_STATE', false)
        this.exchangeData = [...this.currentTableChecked]
        this.exchangeShow = true
      }
    }
  },
  components: {
    HeadNav,
    HeadTabSwitch,
    ConditionInquery,
    CommonTable,
    PaginationTool,
    ImgModify,
    // CustomizedList,
    SendImg,
    SetColumns,
    ImgListTableOperateBtn,
    Exchange,
    Transpond,
    ImportImage,
    imgDeleteDialog
  }
}
</script>
<style lang="less" scoped>
.importDialog {
  /deep/ .el-dialog__header {
    padding-left: 0px;
  }

  /deep/ .el-progress-bar__outer {
    height: 15px !important;
  }
}

.icon.iconTrans {
  display: inline-block;
  animation: move 1.5s linear infinite;
  -webkit-animation: move 1.5s linear infinite;
  font-size: 20px !important;
}

@keyframes move {
  100% {
    transform: rotate(360deg);
  }
}


/deep/ .listRoomClass .el-select__tags-text {
  display: inline-block;
  max-width: 78px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/deep/ .listRoomClass .el-icon-close {
  margin-top: -13px;
  margin-left: -6px;
}

// .el-select {
//    /deep/.el-select__tags {
//      // 解决多个tag卡片溢出隐藏问题
//      overflow: hidden;
//      display: -webkit-box;
//      -webkit-line-clamp: 1;
//      -webkit-box-orient: vertical;
//      .el-tag {
//        // 注意这个inline-block 对卡片溢出隐藏很重要
//        display: inline-block;
//        // 解决单个tag文字过长溢出隐藏问题
//        .el-select__tags-text {
//          display: inline-block;
//          max-width: 70px;
//          overflow: hidden;
//          text-overflow: ellipsis;
//          white-space: nowrap;
//        }

//        .el-icon-close {
//          top: -6px;
//          right: -4px;
//        }
//      }
//    }
//  }
.w180 {
  width: 180px;
}

.bg_000 {
  background-color: #000000;
}

.btnBox {

  // position: absolute;
  // right: 20px;
  // top: 95px;
  // margin-bottom: 20px;
  button {
    width: 70px;
    height: 32px;
    background-color: #fff;
    border: 1px solid #DCDFE6;
    padding: 0;
  }
}

.delingDialog {
  // /deep/ .el-dialog {
  //   margin: auto 50px 50px auto;
  // }

  /deep/ .el-dialog__header {
    background-color: white;
    height: 0px;
  }

  /deep/ .el-dialog__body {
    padding: 10px;
  }
}

.f18i {
  font-size: 18px !important;
}

.f20i {
  font-size: 20px !important;
}

.el-button+.el-button {
  margin-left: 5px;
}

.ml10i {
  margin-left: 10px !important;
}

//   /deep/ .el-table__body tr.current-row>td {
//   // 色值待确定
//   background-color: #0a70b0;
//   color: white;
// }
// /deep/.el-table__fixed .el-table__fixed-body-wrapper{
//   top: 42px !important;
//   // height: 100% !important;  //会有bug  左边序号超过15显示不全 
// }
// /deep/.el-table__row .cell {
//   width: 100% !important;
// }
// /deep/ .el-table .el-table__fixed {
//   height: 100% !important;
// }
// /deep/ .el-table__fixed-body-wrapper .el-table__body{
//   padding-bottom: 8px;//滚动条的高度
// }
.img_box {
  overflow-x: auto;
  display: flex;

  div {
    // height: 200px;
    margin-right: 54px;
    // margin-top: 10px;
    // display: flex;
    // flex-direction: column;
    // justify-content: center;
  }

  // .otherDiv {
  //   height: 180px;
  // }



  /deep/.el-checkbox__input {
    position: absolute;
    top: 188px;
    right: 0;
    /*opacity: 0;*/
  }

  /deep/.el-checkbox__inner {
    width: 20px;
    height: 20px;
  }

  /deep/.el-checkbox__input.is-checked .el-checkbox__inner::after {
    margin-left: 3px;
    transform: rotate(45deg) scale(2)
  }

  /deep/.el-checkbox__inner::after {
    /*去除动画效果*/
    -webkit-transition: none !important;
    -moz-transition: none !important;
    -o-transition: none !important;
    transition: none !important;
  }


}



.imgLoadFail {
  width: 94px;
  height: 90px;
  background: url("../../../assets/images/pacs/imgLoadFail.png") no-repeat;
  background-size: 100% 100%;
}

.noImg {
  width: 58px;
  height: 90px;
  background: url("../../../assets/images/pacs/noImg.png") no-repeat;
  background-size: 100% 100%;
}

.shouldTransform {
  i {
    display: inline-block;
    // &:hover{
    transform: rotate(180deg);
    //     transition: 2s;
    // }
  }

  //  transform: rotate(180deg);
}

.del_btn {
  position: absolute;
  top: 0px;
  right: -12px;
  cursor: pointer;
  z-index: 10;
}
</style>
